package com.example.capsule_netty.controller;

import com.example.capsule_netty.bean.MessageBean;
import com.example.capsule_netty.bean.RoomBean;
import com.example.capsule_netty.global.UserAndChannelRelevance;
import com.example.capsule_netty.service.FieldToMacService;
import com.example.capsule_netty.service.FunctionService;
import com.example.capsule_netty.service.RoomService;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: zhuzhiming
 * @Date: 2022/5/1 23:29
 */
@RestController
@Slf4j
public class RoomController {

    @Autowired
    FieldToMacService fieldToMacService;

    @Autowired
    FunctionService functionService;

    @Autowired
    RoomService roomService;

    @GetMapping("/getRoomList/{userId}/{macAddress}")
    public String getRoomList(@PathVariable String userId, @PathVariable String macAddress) {
        return fieldToMacService.getFieldByMac(userId, macAddress);
    }


    @GetMapping("/getFunctionList/{roomName}")
    public String getFunctionList(@PathVariable String roomName) {
        return functionService.getFunctionList(roomName);
    }

    @GetMapping("getChatRoomFriend/{roomName}")
    public String getChatRoomFriend(@PathVariable String roomName) {
        return roomService.getChatRoomFriend(roomName);
    }

    @GetMapping("searchGroupFriend/{roomName}/{content}")
    public String searchGroupFriend(@PathVariable String roomName, @PathVariable String content) {
        return roomService.doSearchGroupFriend(roomName, content);
    }

    @GetMapping("statisticPeople/{roomName}/{imei}")
    public String statisticPeople(@PathVariable String roomName, @PathVariable String imei) {
        return roomService.doStatisticPeople(roomName, imei);
    }

    @PostMapping("addSecretRoom")
    public String addSecretRoom(@RequestBody MessageBean messageBean) {
        return roomService.doAddSecretRoom(messageBean);
    }
}

